#ifndef CIRCLE_HULL_HPP
#define CIRCLE_HULL_HPP

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "Hull.hpp"

#include <SmegTools/Config.h>
#include <SmegTools/Debug/DebugNew.hpp>

namespace smeg {
    namespace light {

////////////////////////////////////////////////////////////
/// Represent a Circle Hull
/// WARNING : Number of vertices is : center vertex + number of vertex around
////////////////////////////////////////////////////////////
class CircleHull : public Hull
{
public:
    ////////////////////////////////////////////////////////////
    /// Default Constructor
    ///
    /// \param _fRadius :       Radius of the hull
    /// \param _uNumVertices :  Number of vertices for representing the circle
    /// WARNING : Number of vertices is : center vertex + number of vertex around
    /// \param _Center :        Center of the hull
    /// \param _fAngleDeg :     Rotation angle
    /// \param _bIsStatic :     Static or dynamic ?
    /// \param _pParent :       Shadow caster parent if any
    ///
    ////////////////////////////////////////////////////////////
                                CircleHull( float _fRadius                  = 1.0f, 
                                            unsigned _uNumVertices          = 33, 
                                            const sf::Vector2f& _Center     = sf::Vector2f(), 
                                            float _fAngleDeg                = 0.0f,
                                            bool _bIsStatic                 = false,
                                            ShadowCasterEntity* _pParent    = NULL );
    ////////////////////////////////////////////////////////////
    /// Constructor
    ///
    /// \param _Radius :        Radius of the hull (value of X and Y can be different to do an oval)
    /// \param _uNumVertices :  Number of vertices for representing the circle
    /// WARNING : Number of vertices is : center vertex + number of vertex around
    /// \param _Center :        Center of the hull
    /// \param _fAngleDeg :     Rotation angle
    /// \param _bIsStatic :     Static or dynamic ?
    /// \param _pParent :       Shadow caster parent if any
    ///
    ////////////////////////////////////////////////////////////
                                CircleHull( const sf::Vector2f& _Radius, 
                                            unsigned _uNumVertices          = 33, 
                                            const sf::Vector2f& _Center     = sf::Vector2f(), 
                                            float _fAngleDeg                = 0.0f,
                                            bool _bIsStatic                 = false,
                                            ShadowCasterEntity* _pParent    = NULL );
    ////////////////////////////////////////////////////////////
    /// Copy Constructor
    ///
    /// \param _Copy :          Circle Hull to copy from
    ///
    ////////////////////////////////////////////////////////////
                                CircleHull( const CircleHull& _Copy );
    ////////////////////////////////////////////////////////////
    /// Destructor
    ///
    ////////////////////////////////////////////////////////////
    virtual                     ~CircleHull();

    CREATE_CLONE_FUNC( CircleHull, core::BaseEntity );
    
    ////////////////////////////////////////////////////////////
    /// Is the given point inside the hull
    ///
    /// \param _Point :         Point to test
    ///
    /// \return Whether the point is inside the hull or not
    ///
    ////////////////////////////////////////////////////////////
    virtual bool                IsPointInHull( const sf::Vector2f& _Point ) const;
    
    /*********************** Accessors ************************/
    void                        SetRadius( float _fRadius, unsigned _uNumVertices = 33 );
    void                        SetRadius( const sf::Vector2f& _Radius, unsigned _uNumVertices = 33 );
    const sf::Vector2f&         GetRadius() const;

    void                        SetNumVertices( unsigned _uNumVertices );

protected:    
    ////////////////////////////////////////////////////////////
    /// Compute the circle
    ///
    ////////////////////////////////////////////////////////////
    void                        ComputeCircle();
    ////////////////////////////////////////////////////////////
    /// Compute the AABB
    ///
    ////////////////////////////////////////////////////////////
    virtual void                ComputeAABB();

    /******************* Protected members ********************/
    sf::Vector2f                m_Radius;               /// Radius of the circle/oval            
    bool                        m_bChangedNumVertices;  /// Boolean to know if the number of vertices has changed
};

/************************** Inline ************************/
inline const sf::Vector2f& CircleHull::GetRadius() const {
    return m_Radius;
}

    } // namespace light
} // namespace smeg

#include <SmegTools/Debug/DebugNewOff.hpp>

#endif // CIRCLE_HULL_HPP
